unit u_menu_in_game;

interface

uses
u_load,
u_font,
u_player,
sysutils,
system.Drawing,
system.windows.Forms,
Microsoft.DirectX,
Microsoft.DirectX.Direct3D,
Microsoft.DirectX.Direct3DX;

const

  decaly = 140;

type

t_menu_bool_int = record
  bool: boolean;
  bool2: boolean;
  int: integer;
end;

t_coor = record
  x: integer;
  y: integer;
end;

t_text_pos_type = record
  texture: texture;
  cpos: char;
  _type: string;
  pos_con: integer;
end;

t_tab_text = array of t_text_pos_type;

c_menu_in_game = class

  private
    text_or: u_text;
    f_vie_i, f_vie_a, f_vie_m: u_text;
    f_xp_i, f_xp_a, f_xp_m: u_text;
    f_for_i, f_for_a, f_for_m: u_text;
    f_dis_i, f_dis_a, f_dis_m: u_text;
    f_vit_i, f_vit_a, f_vit_m: u_text;
    f_lvl, f_armure, f_degats: u_text;

    ti_vie, ti_lvl, ti_xp: u_text;
    ti_for, ti_dis, ti_vit: u_text;
    ti_armure, ti_port_deg: u_text;

    b_vie, b_vie_e: u_text;
    b_p_v_e, b_p_v: u_text;
    pseudo, typ_en: u_text;

    text_bull: u_text;

    invbool: boolean;
    caracbool: boolean;
    inventaire: texture;
    photo: texture;
    _carac: texture;
    barre_vie: Texture;
    ennemi: texture;
    empl: Texture;
    _sprite: sprite;
    _sprite2: sprite;
    equip: texture;
    b_progre: texture;
    barre_bas: texture;
    ligneh: texture;
    lignev: texture;
    trait: texture;
    bulle: Texture;
    x_carac, y_carac: integer;
    _1_posx, _2_posx: integer;
    tab_text_equip, tab_text_inv: t_tab_text;
  public


    tou_i, p, c: t_menu_bool_int;
    move_menu: boolean;
    procedure render(dev: device; tab: t_tab_cont; heigth, width: integer; carac: t_carac_player;var modif: boolean);
    constructor create(dev: device; carac: t_carac_player; tab: t_tab_cont);
    procedure menu_inv_argent(tab: t_tab_cont);
    procedure barre_carac(carac: t_carac_player);
    procedure menu_ouvert(var _i, _p, _c: t_menu_bool_int);
    procedure set_car_x_y;
    procedure text_menu_carac(carac: t_carac_player);
    procedure gestion_emplacement_inv(carac: t_carac_player);
    procedure gestion_emplacement_equip;
    function test(_i: integer): integer;
    procedure dess_emplace_inv;
    procedure dess_barre_carac;
    procedure dess_emplace_equip;
    function calcul_x_y_emplacement_inv(pos: integer): t_coor;
    function calcul_x_y_emplacement_equip(_type: string; empla: char): t_coor;

    procedure rempli_tab_tex_inv_equip(dev: device; tab: t_tab_cont);

    procedure affiche_text_carac(width, height: integer; tab: t_tab_cont; carac: t_carac_player);
    procedure affiche_text_b_bas(width, height: integer; carac: t_carac_player);
    procedure affiche_text_b_bas_e(width, height: integer; viet, viea: integer; _type: string);
    procedure affi_enne_selec(width, height: integer; selec: boolean; viet, viea: integer; _type: string);
    procedure affi_bulle(mousex, mousey: integer; posi: integer; tab: t_tab_cont);
    procedure find_param_bull(mousex, mousey, width, height: integer; tab: t_tab_cont);



end;

implementation


constructor c_menu_in_game.create;
  begin
    inherited create;
    _sprite := sprite.Create(dev);
    _sprite2 := sprite.Create(dev);
    inventaire := Textureloader.FromFile(dev, 'asus menu\in game\inv1.png');
    _carac := Textureloader.FromFile(dev, 'asus menu\in game\car1.png');
    b_progre := Textureloader.FromFile(dev, 'asus menu\in game\b_prog.png');
    equip := Textureloader.FromFile(dev, 'asus menu\in game\equi1.png');
    barre_bas := Textureloader.FromFile(dev, 'asus menu\in game\barre.bmp');
    photo := Textureloader.FromFile(dev, 'asus menu\in game\testtransp.png');
    empl := textureloader.fromfile(dev, 'asus menu\in game\empl1.png');
    ennemi := TextureLoader.FromFile(dev, 'asus menu\in game\archertransp.png');
    barre_vie := TextureLoader.FromFile(dev, 'asus menu\in game\barre_vie.png');
    trait := TextureLoader.FromFile(dev, 'asus menu\in game\b_plate.png');
    bulle := Textureloader.FromFile(dev, 'asus menu\in game\bulle.png');
    ligneh := Textureloader.FromFile(dev, 'asus menu\in game\ligne.png');
    lignev := Textureloader.FromFile(dev, 'asus menu\in game\lignev.png');
    invbool := false;
    caracbool :=  false;
    text_or := u_text.create(dev, 10, color.Black, '0', 'Comic Sans MS', FontStyle.Regular);
    f_vie_i := u_text.create(dev, 8, color.Black, '', 'Comic Sans MS', FontStyle.regular);
    f_vie_a := u_text.create(dev, 8, color.Black, '', 'Comic Sans MS', FontStyle.regular);
    f_vie_m := u_text.create(dev, 8, color.Black, '', 'Comic Sans MS', FontStyle.regular);
    f_xp_i := u_text.create(dev, 8, color.Black, '', 'Comic Sans MS', FontStyle.regular);
    f_xp_a := u_text.create(dev, 8, color.Black, '', 'Comic Sans MS', FontStyle.regular);
    f_xp_m := u_text.create(dev, 8, color.Black, '', 'Comic Sans MS', FontStyle.regular);
    f_for_i := u_text.create(dev, 8, color.Black, '', 'Comic Sans MS', FontStyle.regular);
    f_for_a := u_text.create(dev, 8, color.Black, '', 'Comic Sans MS', FontStyle.regular);
    f_for_m := u_text.create(dev, 8, color.Black, '', 'Comic Sans MS', FontStyle.regular);
    f_dis_i := u_text.create(dev, 8, color.Black, '', 'Comic Sans MS', FontStyle.regular);
    f_dis_a := u_text.create(dev, 8, color.Black, '', 'Comic Sans MS', FontStyle.regular);
    f_dis_m := u_text.create(dev, 8, color.Black, '', 'Comic Sans MS', FontStyle.regular);
    f_vit_i := u_text.create(dev, 8, color.Black, '', 'Comic Sans MS', FontStyle.regular);
    f_vit_a := u_text.create(dev, 8, color.Black, '', 'Comic Sans MS', FontStyle.regular);
    f_vit_m := u_text.create(dev, 8, color.Black, '', 'Comic Sans MS', FontStyle.regular);
    f_lvl := u_text.create(dev, 8, color.Black, '', 'Comic Sans MS', FontStyle.regular);
    f_degats := u_text.create(dev, 8, color.Black, '', 'Comic Sans MS', FontStyle.regular);
    f_armure := u_text.create(dev, 8, color.Black, '', 'Comic Sans MS', FontStyle.regular);
    ti_vie := u_text.create(dev, 10, color.Black, '', 'Comic Sans MS', FontStyle.Regular);
    ti_lvl := u_text.create(dev, 10, color.Black, '', 'Comic Sans MS', FontStyle.bold);
    ti_xp := u_text.create(dev, 10, color.Black, '', 'Comic Sans MS', FontStyle.bold);
    ti_for := u_text.create(dev, 10, color.Black, '', 'Comic Sans MS', FontStyle.bold);
    ti_dis := u_text.create(dev, 10, color.Black, '', 'Comic Sans MS', FontStyle.bold);
    ti_vit := u_text.create(dev, 10, color.Black, '', 'Comic Sans MS', FontStyle.bold);
    ti_armure := u_text.create(dev, 10, color.Black, '', 'Comic Sans MS', FontStyle.bold);
    ti_port_deg := u_text.create(dev, 10, color.Black, '', 'Comic Sans MS', FontStyle.bold);
    b_vie := u_text.create(dev, 12, color.Black, '', 'Comic Sans MS', FontStyle.bold);
    b_vie_e := u_text.create(dev, 12, color.Black, '', 'Comic Sans MS', FontStyle.bold);
    b_p_v_e := u_text.create(dev, 10, color.Black, '', 'Comic Sans MS', FontStyle.bold);
    b_p_v := u_text.create(dev, 10, color.Black, '', 'Comic Sans MS', FontStyle.bold);
    pseudo := u_text.create(dev, 12, color.Black, '', 'Comic Sans MS', FontStyle.bold);
    typ_en := u_text.create(dev, 12, color.Black, '', 'Comic Sans MS', FontStyle.bold);
    text_bull := u_text.create(dev, 8, Color.Black, '', 'Comic Sans MS', FontStyle.Regular);

    tou_i.bool := false;
    p.bool := false;
    c.bool := false;
    tou_i.int := 0;
    p.int := 0;
    c.int := 0;
    _1_posx := 50;
    _2_posx := 200;
    rempli_tab_tex_inv_equip(dev, tab);
    move_menu := false;
  end;



function c_menu_in_game.test(_i: Integer): integer;
begin
  if _i = 1 then
    result := _1_posx + 5
  else
    Result := _2_posx + 5;
end;

procedure c_menu_in_game.menu_ouvert;
begin


  if _i.bool = false then
    begin
      if _c.int = 2 then
        begin
          _c.int := 0;
          _c.bool := false;
        end
      else
        if _p.int = 2 then
          begin
            _p.int := 0;
            _p.bool := false;
          end;
      if _c.int = 1 then
        _c.int := 2
      else
        if _p.int = 1 then
          _p.int := 2;
      _i.int := 1;
      _i.bool := true;
    end
  else
    if _i.bool = true then
      begin
        if _i.int = 1 then
          if _c.int = 2 then
            _c.int := 1
          else
            if _p.int = 2 then
              _p.int :=1;
        _i.bool := false;
        _i.int := 0;
      end;



end;


procedure c_menu_in_game.affi_enne_selec(width, height: integer; selec: Boolean; viet: Integer; viea: Integer; _type: string);
var
  j: integer;
  z: single;
begin
  _sprite.&begin(SpriteFlags.AlphaBlend);
    _sprite.Draw(ennemi, Vector3.Create(0, 0 ,0), Vector3.Create(20, height - 150, 0), color.White.ToArgb);
    _sprite.Draw(barre_vie, Vector3.Create(0, 0, 0), Vector3.Create(159, height - 76, 0), color.White.ToArgb);
    if viet > 0 then
      begin
        z := (viea * 100) / viet;
        j := 0;
        while j < z do
          begin
            _sprite.Draw(b_progre, Vector3.Create(0, 0, 0), Vector3.Create(160 + j, height - 75, 0), color.White.ToArgb);
            j := j + 1;
          end;
      end;
  _sprite.&End;
  affiche_text_b_bas_e(width, height, viet, viea, _type);
end;

procedure c_menu_in_game.find_param_bull;
var
  i: Integer;
  j, k: integer;
  xi: integer;
  res: integer;
  txxx: integer;
begin
  if tou_i.bool then
    begin
      xi := test(tou_i.int);
      for i := 0 to length(tab_text_inv) - 1 do
        begin
          j := i mod 5;
          k := i div 5;
          if (mousex >= xi + j * 31) and
             (mousex <= xi + 21 + j * 31) and
             (mousey >= decaly + 6 + k * 31) and
             (mousey <= decaly + 6 + 25 + k * 31) then
               Res := tab_text_inv[i].pos_con;
        end
    end;
  if p.bool then
    begin
      xi := test(p.int);
      for i := 0 to length(tab_text_equip) - 1 do
        begin
          if (tab_text_equip[i]._type = 'Ram') and
             (tab_text_equip[i].cpos = 'd') and
             (mousex >= xi + 1) and
             (mousex <= xi + 26) and
             (mousey >= decaly + 6) and
             (mousey <= decaly + 31) then
               Res := tab_text_equip[i].pos_con
          else
            if (tab_text_equip[i]._type = 'Ram') and
               (tab_text_equip[i].cpos = 'g') and
               (mousex >= xi + 94) and
               (mousex <= xi + 119) and
               (mousey >= decaly + 6) and
               (mousey <= decaly + 31) then
                 Res := tab_text_equip[i].pos_con
            else
              if (tab_text_equip[i]._type = 'Processeur') and
                 (tab_text_equip[i].cpos = 'd') and
                 (mousex >= xi + 32) and
                 (mousex <= xi + 57) and
                 (mousey >= decaly + 6) and
                 (mousey <= decaly + 31) then
                   res := tab_text_equip[i].pos_con
              else
                if (tab_text_equip[i]._type = 'Processeur') and
                   (tab_text_equip[i].cpos = 'g') and
                   (mousex >= xi + 63) and
                   (mousex <= xi + 88) and
                   (mousey >= decaly + 6) and
                   (mousey <= decaly + 31) then
                     res := tab_text_equip[i].pos_con
                else
                  if (tab_text_equip[i]._type = 'Carte graphique') and
                     (tab_text_equip[i].cpos = 'd') and
                     (mousex >= xi + 1) and
                     (mousex <= xi + 26) and
                     (mousey >= decaly + 36) and
                     (mousey <= decaly + 61) then
                       res := tab_text_equip[i].pos_con
                  else
                    if (tab_text_equip[i]._type = 'Disque dur') and
                       (tab_text_equip[i].cpos = 'd') and
                       (mousex >= xi + 94) and
                       (mousex <= xi + 119) and
                       (mousey >= decaly + 36) and
                       (mousey <= decaly + 61) then
                         res := tab_text_equip[i].pos_con
                    else
                      if (tab_text_equip[i]._type = 'Armes') and
                         (tab_text_equip[i].cpos = 'd') and
                         (mousex in [xi + 32..xi + 57]) and
                         (mousey >= decaly + 215) and
                         (mousey <= decaly + 240) then
                           res := tab_text_equip[i].pos_con
                      else
                        if (tab_text_equip[i]._type = 'Armes') and
                           (tab_text_equip[i].cpos = 'g') and
                           (mousex in [xi + 63..xi + 88]) and
                           (mousey >= decaly + 215) and
                           (mousey <= decaly + 240) then
                             res := tab_text_equip[i].pos_con
        end;
    end;
  txxx := length(tab[res].nom);
  affi_bulle(mousex, mousey, res, tab);
end;



procedure c_menu_in_game.affi_bulle(mousex: Integer; mousey: Integer; posi: integer; tab: t_tab_cont);
var
  rec: Rectangle;
  rech: Rectangle;
  recv: Rectangle;
  tx, ty: integer;
begin
  if posi <> 0 then
    begin
      tx := (math.Max(length(tab[posi].nom), length(tab[posi]._type))+ 4) * 7;
      if tab[posi].carac2 = 0 then
        ty := 3 * 13
      else
        ty := 4 * 13;
      rec := Rectangle.Create(0, 0, tx, ty);
      recv := Rectangle.Create(0 , 0, 1, ty);
      rech := Rectangle.Create(0, 0, tx, 1);
      _sprite2.&Begin(SpriteFlags.AlphaBlend);
        _sprite2.Draw(bulle, rec, Vector3.Create(0, 0, 0), Vector3.Create(mousex + 15, mousey, 0), Color.White);
        _sprite2.Draw(ligneh, rech, Vector3.Create(0, 0, 0), Vector3.Create(mousex + 15, mousey, 0), color.White);
        _sprite2.Draw(ligneh, rech, Vector3.Create(0, 0, 0), Vector3.Create(mousex + 15, mousey  + ty, 0), color.White);
        _sprite2.Draw(lignev, recv, Vector3.Create(0, 0, 0), Vector3.Create(mousex + 15, mousey, 0), color.White);
        _sprite2.Draw(lignev, recv, Vector3.Create(0, 0, 0), Vector3.Create(mousex + 15 + tx, mousey, 0), color.White);

      _sprite2.&End;
      text_bull.set_coord(mousex + 19, mousey + 1);
      text_bull.change_text('nom: ' + tab[posi].nom);
      text_bull.text_render;
      text_bull.set_coord(mousex + 19, mousey + 13);
      text_bull.change_text('type: ' +tab[posi]._type);
      text_bull.text_render;
      if tab[posi]._type = 'Ram' then
        begin
          text_bull.set_coord(mousex + 19, mousey + 25);
          text_bull.change_text('vitesse + ' + inttostr(tab[posi].carac1));
          text_bull.text_render;
        end
      else
        if tab[posi]._type = 'Processeur' then
          begin
            text_bull.set_coord(mousex + 19, mousey + 25);
            text_bull.change_text('force + ' + inttostr(tab[posi].carac1));
            text_bull.text_render;
          end
        else
          if tab[posi]._type = 'Carte graphique' then
            begin
              text_bull.set_coord(mousex + 19, mousey + 25);
              text_bull.change_text('discretion + ' + inttostr(tab[posi].carac1));
              text_bull.text_render;
            end
          else
            if tab[posi]._type = 'Disque dur' then
              begin
                text_bull.set_coord(mousex + 19, mousey + 25);
                text_bull.change_text( inttostr(tab[posi].carac1) + ' places');
                text_bull.text_render;
              end
            else
              if tab[posi]._type = 'Armes' then
                begin
                  text_bull.set_coord(mousex + 19, mousey + 25);
                  text_bull.change_text('Portee + ' + inttostr(tab[posi].carac1));
                  text_bull.text_render;
                  text_bull.set_coord(mousex + 19, mousey + 37);
                  text_bull.change_text('degats + ' + inttostr(tab[posi].carac2));
                  text_bull.text_render;
                end;


    end;
end;





procedure c_menu_in_game.render;
var
  j: integer;
  z: single;
  begin
    _sprite.&Begin(spriteflags.AlphaBlend);

    _sprite.Draw(barre_bas, Vector3.Create(0, 0, 0), Vector3.Create(width * 0 div 800, heigth - 150, 0), Color.White.ToArgb);
    if carac.vie.stuff > 0 then
      begin
        z := (carac.vie.actuel * 100) / carac.vie.stuff;
        j := 0;
        while j < z do
          begin
            _sprite.Draw(b_progre, Vector3.Create(0, 0, 0), Vector3.Create(width - 245 + j, heigth - 75, 0), color.White.ToArgb);
            j := j + 1;
          end;
      end;
    _sprite.Draw(barre_vie, Vector3.Create(0, 0, 0), Vector3.Create(width - 246, heigth - 76, 0), color.White.ToArgb);
    _sprite.Draw(photo, Vector3.Create(0,0,0), Vector3.Create(width - 125, heigth - 150, 0), color.White.ToArgb);
      if tou_i.bool then
        begin
          if modif then
            begin
              rempli_tab_tex_inv_equip(dev, tab);
              modif := false;
            end;
          case tou_i.int of
            1: _sprite.Draw(inventaire, Vector3.Create(0, 0, 0), Vector3.Create(_1_posx, decaly, 0), Color.White.ToArgb);
            2: _sprite.Draw(inventaire, Vector3.Create(0, 0, 0), Vector3.Create(_2_posx, decaly, 0), Color.White.ToArgb);
          end;
          gestion_emplacement_inv(carac);
          dess_emplace_inv;
        end;
      if c.bool then
        begin
          case c.int of
            1: _sprite.Draw(_carac, Vector3.Create(0, 0, 0), Vector3.Create(_1_posx, decaly, 0.0001), Color.White.ToArgb);
            2: _sprite.Draw(_carac, Vector3.Create(0, 0, 0), Vector3.Create(_2_posx, decaly, 0.0001), Color.White.ToArgb);
          end;
          dess_barre_carac;
          barre_carac(carac);
        end;
      if p.bool then
        begin
          case p.int of
            1: _sprite.Draw(equip, Vector3.Create(0, 0, 0), Vector3.Create(_1_posx, decaly, 0), Color.White.ToArgb);
            2: _sprite.Draw(equip, Vector3.Create(0, 0, 0), Vector3.Create(_2_posx, decaly, 0), Color.White.ToArgb);
          end;
          gestion_emplacement_equip;
          dess_emplace_equip;
        end;
    _sprite.&End;
  end;

procedure c_menu_in_game.affiche_text_carac;
begin
  if c.bool then
    begin
      set_car_x_y;
      text_menu_carac(carac);
    end;
  if tou_i.bool then
    menu_inv_argent(tab);
  affiche_text_b_bas(width, height, carac);
end;

procedure c_menu_in_game.affiche_text_b_bas;
begin
  b_vie.set_coord(width - 210, height - 97);
  b_p_v.set_coord(width - 210, height - 63);
  pseudo.set_coord(width - 193, height - 140);
  pseudo.change_text('Cladaaliy');
  pseudo.text_render;
  b_vie.change_text('PV :');
  b_vie.text_render;
  b_p_v.change_text(inttostr(trunc(carac.vie.actuel * 100 / carac.vie.stuff)) + ' %');
  b_p_v.text_render;

end;


procedure c_menu_in_game.affiche_text_b_bas_e;
begin
  b_vie_e.set_coord(195, height - 97);
  b_p_v_e.set_coord(195, height - 63);
  typ_en.set_coord(120, height - 140);
  typ_en.change_text(_type);
  typ_en.text_render;
  b_vie_e.change_text('PV :');
  b_vie_e.text_render;
  b_p_v_e.change_text(inttostr(trunc(viea * 100 / viet)) + ' %');
  b_p_v_e.text_render;
end;


procedure c_menu_in_game.menu_inv_argent(tab: t_tab_cont);
var
  i: integer;
  xi: integer;
begin
  i := 0;
  xi := test(tou_i.int);
  text_or.set_coord(xi + 15, decaly + 224);
  while (i < length(tab)) and (tab[i]._type <> 'Argent') do
    i := i + 1;
  if tab[i]._type = 'Argent' then
    begin
      text_or.change_text('Euros :  ' +inttostr(Tab[i].quantite));
      text_or.text_render;
    end;
end;

procedure c_menu_in_game.barre_carac;
var
  z: single;
  j: integer;
  x,k: integer;
begin
  if c.int = 1 then
    x := _1_posx
  else
    x := _2_posx;
  if carac.force.stuff in [1..100] then
    _sprite.draw(b_progre, vector3.Create(0, 0, 0), vector3.Create(x + 12 + carac.force.stuff, decaly + 102, 0), color.white.ToArgb);
  if carac.discretion.stuff in [1..100] then
    _sprite.Draw(b_progre, Vector3.Create(0, 0, 0), Vector3.Create(x + 12 + carac.discretion.stuff, decaly + 134, 0), color.white.toargb);
  if carac.vitesse.stuff in [1..100] then
    _sprite.Draw(b_progre, Vector3.Create(0, 0 ,0), Vector3.Create(x + 12 + carac.vitesse.stuff, decaly + 166, 0), color.white.toargb);
  if carac.vie.stuff > 0 then
    begin
      z := (carac.vie.actuel * 100) / carac.vie.stuff;
      j := 0;
      while j < z do
        begin
          _sprite.Draw(b_progre, Vector3.Create(0, 0, 0), Vector3.Create(x + 14 + j, decaly + 34, 0), color.White.ToArgb);
          j := j + 1;
        end;
    end;
  if carac.xp.stuff > 0 then
    begin
      z := (carac.xp.actuel * 100) / carac.xp.stuff;
      j := 0;
      while j < z do
        begin
          _sprite.Draw(b_progre, Vector3.Create(0, 0, 0), Vector3.Create(x + 14 + j, decaly + 70, 0), color.White.ToArgb);
          j := j + 1;
        end;
    end;
end;

procedure c_menu_in_game.set_car_x_y;
var
  x: integer;
begin
  if c.int = 1 then
    x := _1_posx
  else
    x := _2_posx;
  f_vie_i.set_coord(x + 12, decaly + 43);
  f_vie_a.set_coord(x + 60, decaly + 43);
  f_vie_m.set_coord(x + 105, decaly + 43);
  f_xp_i.set_coord(x + 12 , decaly + 77);
  f_xp_a.set_coord(x + 60, decaly + 77);
  f_xp_m.set_coord(x + 105, decaly + 77);
  f_for_i.set_coord(x + 12, decaly + 110);
  f_for_a.set_coord(x + 60, decaly + 110);
  f_for_m.set_coord(x + 105, decaly + 110);
  f_dis_i.set_coord(x + 12, decaly + 141);
  f_dis_a.set_coord(x + 60, decaly + 141);
  f_dis_m.set_coord(x + 105, decaly + 141);
  f_vit_i.set_coord(x + 12, decaly + 173);
  f_vit_a.set_coord(x + 60, decaly + 173);
  f_vit_m.set_coord(x + 105, decaly + 173);
  f_lvl.set_coord(x + 60, decaly + 5);
  f_armure.set_coord(x + 75, decaly + 224);
  f_degats.set_coord(x + 40, decaly + 207 );
  ti_vie.set_coord(x + 60, decaly + 18);
  ti_lvl.set_coord(x + 15, decaly + 2);
  ti_xp.set_coord(x + 60, decaly + 52);
  ti_for.set_coord(x + 45, decaly + 86);
  ti_dis.set_coord(x + 35, decaly + 118);
  ti_vit.set_coord(x + 45, decaly + 149);
  ti_armure.set_coord(x + 15, decaly + 221);
  ti_port_deg.set_coord(x + 15, decaly + 190);
end;

procedure c_menu_in_game.text_menu_carac(carac: t_carac_player);
begin
  f_vie_i.change_text(inttostr(0));
  f_vie_i.text_render;
  f_vie_a.change_text(inttostr(carac.vie.actuel));
  f_vie_a.text_render;
  f_vie_m.change_text(inttostr(carac.vie.stuff));
  f_vie_m.text_render;
  f_xp_i.change_text(inttostr(0));
  f_xp_i.text_render;
  f_xp_a.change_text(inttostr(carac.xp.actuel));
  f_xp_a.text_render;
  f_xp_m.change_text(inttostr(carac.xp.stuff));
  f_xp_m.text_render;
  f_for_i.change_text(inttostr(0));
  f_for_i.text_render;
  f_for_a.change_text(IntToStr(carac.force.stuff));
  f_for_a.text_render;
  f_for_m.change_text(IntToStr(100));
  f_for_m.text_render;
  f_dis_i.change_text(IntToStr(0));
  f_dis_i.text_render;
  f_dis_a.change_text(IntToStr(carac.discretion.stuff));
  f_dis_a.text_render;
  f_dis_m.change_text(IntToStr(100));
  f_dis_m.text_render;
  f_vit_i.change_text(IntToStr(0));
  f_vit_i.text_render;
  f_vit_a.change_text(IntToStr(carac.vitesse.stuff));
  f_vit_a.text_render;
  f_vit_m.change_text(IntToStr(100));
  f_vit_m.text_render;
  f_lvl.change_text(IntToStr(carac.niveau.actuel));
  f_lvl.text_render;
  f_armure.change_text(IntToStr(carac.armure.actuel));
  f_armure.text_render;
  f_degats.change_text(IntToStr(carac.degats.stuff) +  ' / ' + inttostr(carac.portee.stuff));
  f_degats.text_render;
  ti_vie.change_text('Vie :');
  ti_vie.text_render;
  ti_lvl.change_text('Lvl :');
  ti_lvl.text_render;
  ti_xp.change_text('Xp :');
  ti_xp.text_render;
  ti_for.change_text('Force :');
  ti_for.text_render;
  ti_dis.change_text('Discretion :');
  ti_dis.text_render;
  ti_vit.change_text('Vitesse :');
  ti_vit.text_render;
  ti_armure.change_text('Armure :');
  ti_armure.text_render;
  ti_port_deg.change_text('Degats / portee :');
  ti_port_deg.text_render;
end;

procedure c_menu_in_game.gestion_emplacement_inv(carac: t_carac_player);
var
  j, k: integer;
  x, xi, y: integer;
begin
  y := decaly - 20;
  j := 1;
  xi := test(tou_i.int);
  k := carac.taille.stuff;
  while j <= k do
    begin
      y := y + 35;
      x := xi;
      while (j <= k) and (j mod 5 > 0) do
        begin
          _sprite.Draw(empl, vector3.Create(0, 0, 0), Vector3.Create(x, y, 0), color.White.ToArgb);
          x := x + 31;
          j := j + 1;
        end;
      if j <> 0 then
        k := k + 1;
      j := j + 1;
    end;
  _sprite.Draw(trait, Vector3.Create(0, 0, 0), Vector3.Create(xi - 5, decaly + 215, 0), color.White.ToArgb);
end;


procedure c_menu_in_game.gestion_emplacement_equip;
var
  xi: integer;
begin
  xi := test(p.int);
  _sprite.Draw(empl, Vector3.Create(0, 0, 0), Vector3.Create(xi + 1, decaly + 6, 0), color.White.ToArgb);
  _sprite.Draw(empl, vector3.Create(0, 0, 0), Vector3.Create(xi + 32, decaly + 6, 0), color.White.ToArgb);
  _sprite.Draw(empl, Vector3.Create(0, 0, 0), Vector3.Create(xi + 63, decaly + 6, 0), color.White.ToArgb);
  _sprite.Draw(empl, Vector3.Create(0, 0, 0), Vector3.Create(xi + 94, decaly + 6, 0), color.White.ToArgb);
  _sprite.Draw(empl, Vector3.Create(0, 0, 0), Vector3.Create(xi + 1, decaly + 36, 0), color.White.ToArgb);
  _sprite.Draw(empl, Vector3.Create(0, 0, 0), Vector3.Create(xi + 94, decaly + 36, 0), Color.White.ToArgb);
  _sprite.Draw(empl, Vector3.Create(0, 0, 0), Vector3.Create(xi + 32, decaly + 215, 0), color.White.ToArgb);
  _sprite.Draw(empl, Vector3.Create(0, 0, 0), Vector3.Create(xi + 63, decaly + 215, 0), color.White.ToArgb);
end;


procedure c_menu_in_game.dess_emplace_inv;
var
  i: integer;
  pos:t_coor;
begin
  for i := 0 to length(tab_text_inv) - 1 do
    begin
      pos := calcul_x_y_emplacement_inv(i);
      _sprite.Draw(tab_text_inv[i].texture, Vector3.Create(0, 0, 0), Vector3.Create(pos.x, pos.y, 0), Color.White.ToArgb);
    end;

end;

function c_menu_in_game.calcul_x_y_emplacement_inv;
var
  xi: integer;
  posx: integer;
  posy: integer;
begin
  xi := test(tou_i.int);
  posx := pos mod 4;
  result.x := xi + 31 * posx;
  posy := pos div 4;
  Result.y := decaly + 15+ (posy ) * 35
end;


procedure c_menu_in_game.dess_emplace_equip;
var
  i: integer;
  pos: t_coor;
begin
  for i := 0 to length(tab_text_equip) - 1 do
    begin
      pos := calcul_x_y_emplacement_equip(tab_text_equip[i]._type, tab_text_equip[i].cpos);
      _sprite.Draw(tab_text_equip[i].texture, Vector3.Create(0, 0, 0), Vector3.Create(pos.x, pos.y, 0), Color.White.ToArgb);
    end;
end;


procedure c_menu_in_game.dess_barre_carac;
var
  xi: integer;
begin
  xi := test(c.int);
  _sprite.Draw(barre_vie, Vector3.Create(0, 0 ,0), Vector3.Create(xi + 8, decaly + 33, 0), color.White.ToArgb);
  _sprite.Draw(barre_vie, Vector3.Create(0, 0 ,0), Vector3.Create(xi + 8, decaly + 69, 0), color.White.ToArgb);
  _sprite.Draw(barre_vie, Vector3.Create(0, 0 ,0), Vector3.Create(xi + 7, decaly + 101, 0), color.White.ToArgb);
  _sprite.Draw(barre_vie, Vector3.Create(0, 0 ,0), Vector3.Create(xi + 7, decaly + 133, 0), color.White.ToArgb);
  _sprite.Draw(barre_vie, Vector3.Create(0, 0 ,0), Vector3.Create(xi + 7, decaly + 165, 0), color.White.ToArgb);
end;



function c_menu_in_game.calcul_x_y_emplacement_equip;
var
  xi: integer;
begin
  xi := test(p.int);
  if _type = 'Carte graphique' then
    begin
      Result.x := xi + 1;
      Result.y := decaly + 36;
    end
  else
    if _type = 'Disque dur' then
      begin
        Result.x := xi + 94;
        Result.y := decaly + 36;
      end
    else
      if _type = 'Ram' then
        if empla = 'd' then
          begin
            Result.x := xi + 1;
            Result.y := decaly + 6;
          end
        else
          begin
            Result.x := xi + 94;
            Result.y := decaly + 6;
          end
      else
        if _type = 'Processeur' then
          if empla = 'd' then
            begin
              result.x := xi + 32;
              Result.y := decaly + 6;
            end
          else
            begin
              result.x := xi + 63;
              Result.y := decaly + 6;
            end
        else
          if _type = 'Armes' then
            if empla = 'd' then
              begin
                Result.x := xi + 32;
                Result.y := decaly + 215;
              end
            else
              begin
                Result.x := xi + 63;
                Result.y := decaly + 215;
              end;


end;

procedure c_menu_in_game.rempli_tab_tex_inv_equip(dev: Device; tab: t_tab_cont);
var
  i: integer;
begin
  SetLength(tab_text_equip, 0);
  SetLength(tab_text_inv, 0);
  for i := 0 to length(tab) - 1 do
    begin
      if (tab[i].equip = false) and (tab[i]._type <> 'Argent') and (tab[i].icone <> '') then
        begin
          SetLength(tab_text_inv, length(tab_text_inv) + 1);
          tab_text_inv[Length(tab_text_inv) - 1].texture := TextureLoader.FromFile(dev, tab[i].icone);
          tab_text_inv[Length(tab_text_inv) - 1].pos_con := i;
        end;
    end;
  for i := 0 to length(tab) - 1 do
    begin
      if (tab[i].equip = true) and (tab[i]._type <> 'Argent') and (tab[i].icone <> '') then
        begin
          SetLength(tab_text_equip, length(tab_text_equip) + 1);
          tab_text_equip[Length(tab_text_equip) - 1].texture := TextureLoader.FromFile(dev, tab[i].icone);
          tab_text_equip[Length(tab_text_equip) - 1].cpos := Tab[i].g_d;
          tab_text_equip[Length(tab_text_equip) - 1]._type := tab[i]._type;
          tab_text_equip[Length(tab_text_equip) - 1].pos_con := i;
        end;
    end;
end;


end.
